package com.example.springboot.service.impl;

import com.example.springboot.entity.jobs;
import com.example.springboot.mapper.JobSearchMapper;
import com.example.springboot.service.JobSearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Auther:啊对对对 DATE:2024/6/20 23:28
 * @Description:
 * @Version 1.0
 */

@Service
public class JobSearchServiceImpl implements JobSearchService {

    private final JobSearchMapper jobSearchMapper;

    public JobSearchServiceImpl(JobSearchMapper jobSearchMapper) {
        this.jobSearchMapper = jobSearchMapper;
    }

    // 搜索所有岗位
    @Override
    public List<jobs> findAllJobs() {
        return jobSearchMapper.findAllJobs();
    }

    @Override
    public List<jobs> getEnterprisesPage(int page, int size) {
        int offset = (page - 1) * size;
        return jobSearchMapper.getEnterprisesPage(offset, size);
    }

    // 根据薪资排序搜索岗位
    @Override
    public List<jobs> findJobsBySalary(String order) {
        return jobSearchMapper.findJobsBySalary(JobSearchMapper.SalaryOrder.valueOf(order));
    }

    // 根据发布日期排序搜索岗位
    @Override
    public List<jobs> findJobsByPublishDate(String order) {
        return jobSearchMapper.findJobsByPublishDate(JobSearchMapper.PublishDateOrder.valueOf(order));
    }

    // 根据工作地点搜索职位
    @Override
    public List<jobs> findJobsByLocation(String location) {
        return jobSearchMapper.findJobsByLocation(location);
    }

    // 根据公司id搜索职位
    @Override
    public List<jobs> findJobsByCompanyId(Long companyId) {
        return jobSearchMapper.findJobsByCompanyId(companyId);
    }

    // 根据职位id搜索
    @Override
    public jobs findJobById(Long jobId) {
        return jobSearchMapper.findJobById(jobId);
    }

    // 根据职位标题搜索
    @Override
    public List<jobs> findJobsByJobTitle(String jobTitle) {
        return jobSearchMapper.findJobsByJobTitle(jobTitle);
    }

}
